package interceptor;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
import controller.DirtyAction;

/**
 *
 * 这个类是进行文字过滤
 */
public class DirtyWordInterceptro extends MethodFilterInterceptor {
    @Override
    protected String doIntercept(ActionInvocation invocation) throws Exception {
      DirtyAction dirtyAction = (DirtyAction) invocation.getProxy().getAction();
      //这个是拿到Action中的name
      String name = dirtyAction.getName();
      if (name!=null&&name.contains("妈的")){
        name = name.replace("妈的","**");
        dirtyAction.setName(name);
      }
      if (name!=null&&name.contains("垃圾")){
         name =  name.replace("垃圾","**");
         dirtyAction.setName(name);
        }
        return "addUserTrue";
      //  return invocation.invoke();
    }
}
